<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h2><fmt:message key = "form.listOrganizations"/></h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<div class="links">
<ul class = "navbar2">
   <li>
      <a class = "control" href = 'operatorui?_action=organizationForm'>
         <fmt:message key = "Command.add"/>
      </a>
   </li>           
</ul>
</div>

<form action = "operatorui" method = "post" name = "organizationListForm">
   <table class = "regular">
      <thead>
         <tr>            
            <th><fmt:message key = "organization.shorttitle"/></th>
            <th><fmt:message key = "organization.tel1"/></th>
            <th><fmt:message key = "organization.fax"/></th>
            <th><fmt:message key = "organization.email1"/></th>
            <th><fmt:message key = "organization.www"/></th>
            <th><fmt:message key = "organization.businesstype"/></th>
            <th><fmt:message key = "organization.operations"/></th>
         </tr>
      </thead>

      <tbody>
      	<c:choose>
        <c:when test="${fn:length(organizationsList) != 0}">
         <c:forEach var = "organization" items = "${organizationsList}">
            <tr>
               <td>${organization.shortTitle}</td>
               <td>${organization.tel1}</td>
               <td>${organization.fax}</td>
               <td>${organization.email1}</td>
               <td>${organization.www}</td>
               <td>${organization.businessType}</td>
               <td>
                  <ul class = "navbar2">
                     <li>
                        <a class = "control" href = 'operatorui?_action=listDepartments&organization_id=${organization.id}'>
                           <fmt:message key = "organization.operations.department"/>
                        </a>   
                     </li>
                     <li>
                        <a class = "control" href = 'operatorui?_action=organizationForm&organization_id=${organization.id}'>
                           <fmt:message key = "client.operations.edit"/>
                        </a>
                     </li>
                  </ul>   
               </td>
            </tr>
         </c:forEach>
         </c:when>
       <c:otherwise>
        <tr><td colspan = "7"><center><fmt:message key="emptyList"/></center></td></tr>
       </c:otherwise>     
      </c:choose>     
      </tbody>

      <tfoot>
         <tr>
            <th colspan = "7">
               <fmt:message key = "organization.total"/>:
               <fmt:formatNumber value = '${fn:length(organizationsList)}'/>
            </th>
         </tr>
      </tfoot>
   </table>
   <input name = "_action" type = "hidden">   
</form>

<div class = "links">
  <ul class = "navbar2">
   <li>
      <a class = "control" href = 'operatorui?_action=organizationForm'>
         <fmt:message key = "Command.add"/>
      </a>
   </li>           
  </ul> 
</div>
